import { createRouter, createWebHistory } from "vue-router";
import { userInsert } from '@/api/base'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
        path: "/",
        name: "ProductCenter",
        component: () => import("@/views/pages/Login/index.vue"),
        meta: {
          title: "产品中心",
        },
      },
 
  ],
  //滚动条位置
  scrollBehavior(to, from, savedPosition) {
    // return 期望滚动到哪个的位置
    return { top: 0 }
  }
});
router.afterEach( async (to, from) =>{
  // 埋点
    try {
      const res = await userInsert({pageName:to.meta.title as string})
      if (res.status == 0) {
      } else {
        console.log('error')
      }
    } catch (error) {
      console.log('error: ', error)
    }
})
export default router;
